<script type="text/javascript" src="{lib file=goodsinfo.js}" charset="utf-8"></script>
<script type="text/javascript">
    var market_ratio={$goods.market_price}/{$goods._specs.0.price};
//<!CDATA[
/* buy */
function buy()
{

    if (goodsspec.getSpec() == null)
    {
        alert(lang.select_specs);
        return;
    }
    var spec_id = goodsspec.getSpec().id;

    var quantity = $("#quantity").val();
    if (quantity == '')
    {
        alert(lang.input_quantity);
        return;
    }
    if (parseInt(quantity) < 1)
    {
        alert(lang.invalid_quantity);
        return;
    }
    add_to_cart(spec_id, quantity);
}

/* add cart */
function add_to_cart(spec_id, quantity)
{
    var url = SITE_URL + '/index.php?app=cart&act=add';
    $.getJSON(url, {'spec_id':spec_id, 'quantity':quantity}, function(data){
        if (data.done)
        {
            $('.bold_num').text(data.retval.cart.kinds);
            $('.bold_mly').html(price_format(data.retval.cart.amount));
            $('.ware_cen').slideDown('slow');
            setTimeout(slideUp_fn, 5000);
        }
        else
        {
            alert(data.msg);
        }
    });
}

    /*buy_now*/
    function buy_now()
    {
        //验证数据
        if (goodsspec.getSpec() == null)
        {
            alert(lang.select_specs);
                return;
            }
            var spec_id = goodsspec.getSpec().id;

            var quantity = $("#quantity").val();
            if (quantity == '')
            {
                alert(lang.input_quantity);
                return;
            }
            if (parseInt(quantity) < 1)
            {
                alert(lang.invalid_quantity);
                return;
            }
            buy_now_add_cart(spec_id, quantity);
        }

        /* add buy_now_add_cart */
        function buy_now_add_cart(spec_id, quantity)
        {
            var url = SITE_URL + '/index.php?app=order&goods=single&store_id={$store.store_id}&share_id={$smarty.get.share_id}&spec_id='+spec_id+'&quantity='+quantity;
            location.href=url;return;
        }

var specs = new Array();
<!--{foreach from=$goods._specs item=spec}-->
<!--{if $spec.is_pro}-->
specs.push(new spec({$spec.spec_id}, '{$spec.spec_1|escape}', '{$spec.spec_2|escape}', '{$spec.spec_3|escape}', '{$spec.spec_4|escape}', {$spec.price},{$spec.pro_price}, {$spec.stock},true,{$spec.discount|default:0}));
<!--{else}-->
specs.push(new spec({$spec.spec_id}, '{$spec.spec_1|escape}', '{$spec.spec_2|escape}', '{$spec.spec_3|escape}', '{$spec.spec_4|escape}', {$spec.price},0, {$spec.stock},false,{$spec.discount|default:0}));
<!--{/if}-->
<!--{/foreach}-->
var specQty = {$goods.spec_qty};
var defSpec = {$goods.default_spec|escape};
var goodsspec = new goodsspec(specs, specQty, defSpec);


//]]>

    function decrease_quantity() {
        var item = $('#quantity');
        var orig = Number(item.val());
        if (orig > 1) {
            item.val(orig - 1);
            item.keyup();
        }
    }
    function add_quantity() {
        var item = $('#quantity');
        var orig = Number(item.val());
        item.val(orig + 1);
        item.keyup();
    }
</script>

<div class="ware_info clearfix">
    <div class="ware_pic">
        <div class="big_pic">
            <a href="javascript:;"><span class="jqzoom"><img src="{$goods._images.0.thumbnail|default:$default_image}" width="350" height="350" jqimg="{$goods._images.0.image_url}" /></span></a>
        </div>

        <div class="bottom_btn">
            <div class="left_btn"></div>
            <div class="right_btn"></div>
            <div class="ware_box">
                <ul>
                    <!--{foreach from=$goods._images item=goods_image name=fe_goods_image}-->
                    <li {if $smarty.foreach.fe_goods_image.first}class="ware_pic_hover"{/if} bigimg="{$goods_image.image_url}"><img src="{$goods_image.thumbnail}" width="50" height="50" /></li>
                    <!--{/foreach}-->
                </ul>
            </div>
        </div>
    </div>

    <div class="ware_text">
        <h2 class="ware_title">{$goods.goods_name|escape}</h2>
        <h3 class="goods_subname">{$goods.goods_subname|escape}</h3>

        <div class="ware_price">
            <!--{if $goods.market_price>0}-->
            <dl class="clearfix">
                <dt>{$lang.market_price}：</dt>
                <dd ectype="market_price" class="market_price">{$goods.market_price|price}</dd>
            </dl>
			<div style="clear:both;height:0; display:block; overflow:hidden"></div>
            <!--{/if}-->
            <dl class="clearfix">
                <dt>{$lang.price}：</dt>
                <dd ectype="goods_price" class="goods_price">{$goods._specs.0.price|price}</dd>
            </dl>
         <div style="clear:both;height:0; display:block; overflow:hidden"></div>
            <dl class="clearfix" ectype="is_pro" style="{if !$goods._specs.0.is_pro}display:none{/if}">
                <dt>{$lang.goods_type_pro}：</dt>
                <dd>
                    <span class="pro_price" ectype="goods_pro_price">{$goods._specs.0.pro_price|price}</span>
                    <em class="pro_name" title="{$goods.pro_desc}">{$goods.pro_name}</em>
                    <div class="countdown J_Countdown_GoodsPromotion">
                        <span class="lefttime">{$lang.the_remaining}</span>
                        <span class="flip-top J_NumDays">{$goods.lefttime.d}</span><em>{$lang.day}</em>
                        <span class="flip-top J_NumHours">{$goods.lefttime.h}</span><em>{$lang.hour}</em>
                        <span class="flip-top J_NumMins">{$goods.lefttime.m}</span><em>{$lang.minute}</em>
                        <span class="flip-top J_NumSeconds">{$goods.lefttime.s}</span><em>{$lang.seconds}</em>
                    </div>
                </dd>
            </dl>
          <div style="clear:both;height:0; display:block; overflow:hidden"></div>
            <!--{if $goods.if_open}-->
            <dl class="clearfix">
                <dt>{$lang.goods_type_vip}：</dt>
                <dd>
                    <!--{if $visitor.user_id }-->
                    <span class="member_price" ectype="member_price">{$goods._specs.0.member_price|price}</span><em class="grade_name" title="{$goods.grade_name}">{$goods.grade_name}</em>
                    <!--{else}-->
                    <em class="grade_name" >{$lang.login_check_privit}</em>
                    <!--{/if}-->
                </dd>
            </dl>
			<div style="clear:both;height:0; display:block; overflow:hidden"></div>
            <!--{/if}-->
            <!--{if $store.enable_free_fee or $goods.integral_max_exchange_money}-->
            <dl class="clearfix">
                <dt>{$lang.goods_discount}：</dt>
                <dd>
                    <!--{if $store.enable_free_fee}-->
                    <div  class="notice">
                        <em>{$lang.full_packmail}</em>
                        <!--{if $store.amount_for_free_fee neq '0.00'}--><span>{$lang.man}{$store.amount_for_free_fee|price}{$lang.yuan_shipping}</span><!--{/if}-->
                        <!--{if $store.acount_for_free_fee}--><span>{$lang.man}{$store.acount_for_free_fee|escape}{$lang.jian_shipping}</span><!--{/if}-->
                    </div>
                    <!--{/if}-->
                    <!--{if $goods.integral_max_exchange_money}-->
                    <div  class="notice"><em>{$lang.deduct_points}</em><span>{$lang.points_worth}{$goods.integral_max_exchange_money}{$lang.yuan}</span></div>
                    <!--{/if}-->
                </dd>
            </dl>
			<div style="clear:both;height:0; display:block; overflow:hidden"></div>
            <!--{/if}-->
        </div>

        <div class="rate">
            <!--{if $goods.brand}-->
            <dl class="clearfix">
                <dt>{$lang.brand}: </dt>
                <dd>{$goods.brand|escape}</dd>
            </dl>
			<div style="clear:both;height:0; display:block; overflow:hidden"></div>
            <!--{/if}-->
            <!--{if $goods.tags}-->
            <dl class="clearfix">
                <dt>{$lang.tags}: </dt>
                <dd><!--{foreach from=$goods.tags item=tag}-->{$tag}&nbsp;&nbsp;&nbsp;<!--{/foreach}--></dd>
            </dl>
			<div style="clear:both;height:0; display:block; overflow:hidden"></div>
            <!--{/if}-->
            <dl class="clearfix">
                <dt>{$lang.sale_situation}：</dt>
                <dd>{$sales_info}{$comments}</dd>
            </dl>
			<div style="clear:both;height:0; display:block; overflow:hidden"></div>
            <dl class="clearfix">
                <dt>{$lang.region}：</dt>
                <dd>
                    {$store.region_name|escape}
                </dd>
            </dl>
			<div style="clear:both;height:0; display:block; overflow:hidden"></div>
        </div>

        <div class="handle">
           <!--{if $goods.spec_name_1}-->
            <ul id='handle_1'>
                <li class="handle_title">{$goods.spec_name_1|escape}: </li>
            </ul>
            <!--{/if}-->
            <!--{if $goods.spec_name_2}-->
            <ul id='handle_2'>
                <li class="handle_title">{$goods.spec_name_2|escape}: </li>
            </ul>
            <!--{/if}-->
            <!--{if $goods.spec_name_3}-->
            <ul id='handle_3'>
                <li class="handle_title">{$goods.spec_name_3|escape}: </li>
            </ul>
            <!--{/if}-->
            <!--{if $goods.spec_name_4}-->
            <ul id='handle_4'>
                <li class="handle_title">{$goods.spec_name_4|escape}: </li>
            </ul>
            <!--{/if}-->
            <ul>
                <li class="handle_title">{$lang.quantity}:&nbsp;&nbsp;</li>
                <li class="num">
                    <a class="reduce" href="javascript:decrease_quantity()">-</a>
                    <input type="text"  name="" id="quantity" value="1" />
                    <a class="increase" href="javascript:add_quantity()">﹢</a>
                </li>
                <li class="stock">
                    {$lang.left_bracket}{$lang.stock}<span class="stock" ectype="goods_stock">{$goods._specs.0.stock}</span>{$lang.unit}{$lang.right_bracket}
                </li>
            </ul>
            <!--{if $goods.spec_qty gt 0}-->
            <ul>
                <li class="handle_title">{$lang.your_select}: </li>
                <li class="aggregate" ectype="current_spec"></li>
            </ul>
            <!--{/if}-->
        </div>

        <ul class="ware_btn">
            <div class="ware_cen" style="display:none">
                <div class="ware_center">
                    <h1>
                        <span class="dialog_title">{$lang.add_to_cart_ok}</span>
                        <span class="close_link" title="{$lang.close}" onmouseover="this.className = 'close_hover'" onmouseout="this.className = 'close_link'" onclick="slideUp_fn();"></span>
                    </h1>
                    <div class="ware_cen_btn">
                        <p class="ware_text_p">{$lang.cart_status}</p>
                        <p class="ware_text_btn">
                            <input type="submit" class="btn1" name="" value="{$lang.view_cart}" onclick="location.href = '{$site_url}/index.php?app=cart'" />
                            <input type="submit" class="btn2" name="" value="{$lang.continue_buy}" onclick="$('.ware_cen').css({'display': 'none'});" />
                        </p>
                    </div>
                </div>
                <div class="ware_cen_bottom"></div>
            </div>

            <li class="btn_c1" title="{$lang.buy_now}"><a href="javascript:buy_now();">{$lang.purchase_now}</a></li>
            <li class="btn_c2" title="{$lang.add_to_cart}"><a href="javascript:buy();">{$lang.add_to_cart}</a></li>
            <!--<li class="btn_c3" title="{$lang.add_to_favorite}"><a href="javascript:collect_goods({$goods.goods_id});"></a></li>-->
            <li><a href="javascript:void();" class="btn_phone">
                <em></em>{$lang.go_mobile}
                <div class="phone_qrcode"><span class="arr"></span>
                    <div class="qrcode">{$goods.scan_code}</div>
                </div>
            </a></li>
        </ul>
        <div class="detail_pay"><em class="metatit">{$lang.payment_name}：</em>
            <span>{$lang.alipay}</span><i class="vline">|</i><span>{$lang.online_bank}</span>
        </div>

        <div class="detail_action">
            <div id="bdshare" class="bdshare_t bds_tools get-codes-bdshare">
                <span class="bds_more">{$lang.share_goods}</span>
            </div>
            <script type="text/javascript" id="bdshare_js" data="type=tools&amp;uid=6780915" src="http://bdimg.share.baidu.com/static/js/bds_s_v2.js?cdnversion=390773"></script>
            <span class="favorite_area"><a id="js_add_fav_btn" href="javascript:{if $if_collected}un{/if}collect_goods({$goods.goods_id});" class="collect_btn {if $if_collected}active{/if}">{$lang.collect_goods}</a></span>
        </div>

    </div>
</div>